package com.taptech.doufu.services;

import java.util.LinkedList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import com.taptech.doufu.constant.Constant;
import com.taptech.doufu.listener.HttpResponseListener;
import com.taptech.doufu.net.httputils.HttpRequestObject;
import com.taptech.doufu.net.httputils.HttpUtil;

public class MangerService {
	public static final int  HANDLE_TYPE_MANGER_DEL=8005;
	public static final int  HANDLE_TYPE_MANGER_SWEEP_DEL=8006;
	public static final int HANDLE_TYPE_DELETE_COLLECT = 8008;
	public static MangerService instance=new MangerService();
	public static MangerService getInstance() {
		return instance;
	}
	

	/**
	 * 删除 话题，小说
	 * @param id
	 * @param listener
	 */
	public void mangerDelTopic(String id,HttpResponseListener listener){
		HttpRequestObject request = new HttpRequestObject();
		request.setHandleType(HANDLE_TYPE_MANGER_DEL);
		List<NameValuePair> list = new LinkedList<NameValuePair>();
		NameValuePair value;
		value = new BasicNameValuePair("id", id);
		list.add(value); 
		request.setData(list);
		request.setUrl(Constant.HOST_NAME_SECOND + "/index.php/post/removeTopic");
		request.setListener(listener);
		HttpUtil.sendPostRequest(request);
	}
	/***
	 * 删除文评
	 * @param id
	 * @param listener
	 */
	public void mangerDelSweep(String id,HttpResponseListener listener){
		HttpRequestObject request = new HttpRequestObject();
		request.setHandleType(HANDLE_TYPE_MANGER_SWEEP_DEL);
		List<NameValuePair> list = new LinkedList<NameValuePair>();
		NameValuePair value;
		value = new BasicNameValuePair("review_id", id);
		list.add(value); 
		request.setData(list);
		request.setUrl(Constant.HOST_NAME_SECOND + "/index.php/novel_review/remove");
		request.setListener(listener);
		HttpUtil.sendPostRequest(request);
	}

	public void deleteObjectCollect(String id , String object_type , HttpResponseListener listener){
		HttpRequestObject request = new HttpRequestObject();
		request.setHandleType(HANDLE_TYPE_DELETE_COLLECT);
		List<NameValuePair> list = new LinkedList<NameValuePair>();
		NameValuePair value;
		value = new BasicNameValuePair("id", id);
		list.add(value);
		value = new BasicNameValuePair("object_type", object_type);
		list.add(value);
		request.setData(list);
		request.setUrl(Constant.HOST_NAME_SECOND + "/index.php/favorite/remove");
		request.setListener(listener);
		HttpUtil.sendPostRequest(request);
	}
}
